var Controller = require("Controller");
cc.Class({
    extends: cc.Component,

    properties: {
        cropsIndex : 0,
        pic : cc.Sprite,
        lab : cc.Label,
        controller : Controller,
    },

    // LIFE-CYCLE CALLBACKS:

    // onLoad () {},

    start () {

    },

    init(){
        var ins_crop = this.controller.m_crops[this.cropsIndex];//.stages[0].picture;
        var path = ins_crop.stages[ins_crop.stages.length-1].picture;
        cc.loader.loadRes(path,function(err,spriteFrame){  
            this.pic.spriteFrame=new cc.SpriteFrame(spriteFrame);
        }.bind(this));
        //this.pic.spriteFrame = new cc.SpriteFrame(cc.url.raw(path));
        this.lab.string = ins_crop.cost;
        this.lab.color = new cc.color(255,255,0,255);
        this.node.on(cc.Node.EventType.TOUCH_END,function(t){
            this.controller.choose_buy = this.cropsIndex;
        },this);
    },
    

    // update (dt) {},
});
